<?php

namespace App\Models\Oauth;

use Illuminate\Support\Facades\DB;
use App\Models\Model;

/**
 * 用户第3方授权登录接口
 */
class UserLoginOauthModel extends Model
{

    const TABLENAME = 'tw_base_user_login_oauth';

    //登录类型 1-微信 2-QQ 3-其他
    const TYPE_WEIXIN = 1;
    const TYPE_QQ = 2;
    const TYPE_OTHER = 3;

    //status数据的状态 0:正常 1:失效
    const STATUS_NOMAL = 0;
    const STATUS_BAN = 1;


    /**
     * 初始化并返回数据库请求构建器
     *
     * @return Illuminate\Support\Facades\DB::table(TABLENAME)
     */
    public static function dbTable()
    {
        return DB::table(self::TABLENAME);
    }

    /**
     * 获取用户类型
     */
    public static function getLoginOauth($where)
    {
        return self::dbTable()->select()->where($where)->first();
    }

    /**
     * 添加用户类型关联
     */
    public static function addLoginOauth($data = array())
    {
        return self::dbTable()->insert($data);
    }

    public static function updateLoginOauth($where, $data)
    {
        return self::dbTable()->where($where)->update($data);
    }

    /**
     * 获取
     */
    public static function getLoginOauths($where)
    {
        return self::dbTable()->select()->where($where)->get();
    }
}

?>